

//
//  MyContactServiceCell.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/12/10.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "MyContactServiceCell.h"
#import "ServiceModel.h"
@interface MyContactServiceCell()
@property (weak, nonatomic) IBOutlet UIView *view;
@property (weak, nonatomic) IBOutlet UIImageView *iv;
@property (weak, nonatomic) IBOutlet UILabel *titleL;
@property (weak, nonatomic) IBOutlet UILabel *resourceL;
@property (weak, nonatomic) IBOutlet UIButton *evaluateBtn;
@property (weak, nonatomic) IBOutlet UIButton *oneMoreContact;

@end
@implementation MyContactServiceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.view.layer.cornerRadius = 3;
    self.view.layer.borderColor = k187Color.CGColor;
    self.view.layer.borderWidth = 1;
    self.iv.layer.borderColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1].CGColor;
    self.iv.layer.borderWidth = 1;
    self.iv.layer.cornerRadius = 6;
    self.iv.layer.masksToBounds = YES;
    self.evaluateBtn.layer.masksToBounds = YES;
    self.evaluateBtn.layer.cornerRadius = 3;
    self.oneMoreContact.layer.masksToBounds = YES;
    self.oneMoreContact.layer.cornerRadius = 3;
    [self.oneMoreContact setTitleColor:[UIColor colorWithRed:151/255.0 green:193/255.0 blue:91/255.0 alpha:1] forState:UIControlStateNormal];
}
- (void)setIndexPath:(NSIndexPath *)indexPath
{
    _indexPath = indexPath;
}
- (IBAction)reworkContactBtn:(UIButton *)sender {
    NSMutableString * callPhone= [[NSMutableString alloc] initWithFormat:@"tel:%@",self.serviceModel.phone];
    if (@available(iOS 10.0, *)) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
    } else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
    }
}
- (IBAction)eveluateBtn:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(myContactServiceCell:withEvaluateBtn:withModel:withIndexPath:)]) {
        [self.delegate myContactServiceCell:self withEvaluateBtn:sender withModel:self.serviceModel withIndexPath:self.indexPath];
    }
}
- (void)setServiceModel:(ServiceModel *)serviceModel
{
    _serviceModel = serviceModel;
    if (serviceModel.typeSub2List.count) {
        if (serviceModel.typeSub2List.count ==1) {
            self.titleL.text = [NSString stringWithFormat:@"%@|%@",serviceModel.associationtype,serviceModel.typeSub2List[0]];
        }else {
            self.titleL.text = [NSString stringWithFormat:@"%@|%@|%@",serviceModel.associationtype,serviceModel.typeSub2List[0],serviceModel.typeSub2List[1]];
        }
    }
//    self.titleL.text = [NSString stringWithFormat:@"%@|%@|%@",serviceModel.associationtype,serviceModel.commonIndustryList[0],serviceModel.industryList[0]];
    if (serviceModel.evaluateStatus == 1) {
        [self.evaluateBtn setTitle:@"已评价" forState:UIControlStateNormal];
        self.evaluateBtn.userInteractionEnabled = NO;
        [self.evaluateBtn setTitleColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1] forState:UIControlStateNormal];
    }else {
        [self.evaluateBtn setTitle:@"点击评价" forState:UIControlStateNormal];
        self.evaluateBtn.userInteractionEnabled = YES;
        [self.evaluateBtn setTitleColor:[UIColor colorWithRed:242/255.0 green:156/255.0 blue:56/255.0 alpha:1] forState:UIControlStateNormal];
    }
    [self.iv sd_setImageWithURL:[NSURL URLWithString:serviceModel.logo] placeholderImage:[UIImage imageNamed:@"headImg"]];
    self.resourceL.text = [NSString stringWithFormat:@"服务概述:%@",serviceModel.resource];
}
@end
